import { reactive, ref } from "vue";
import { getListApi as getMasterialApi } from "@/api/configCenter/material";
export default function InitHook() {
  const formDataRef = ref<any>(null);
  const loading = ref<boolean>(false);
  const formState = reactive<Partial<{ materialQualityId: string; materialQualityName: string }>>({
    materialQualityId: undefined,
    materialQualityName: undefined
  });
  const materialOpts = ref<Array<MaterialIndex.ListRows>>([]);
  const getAllMaterialOpts = () => {
    return getMasterialApi({ pageNum: 1, pageSize: 999999, isShow: 1, status: 1 } as MaterialIndex.SearchForm).then((res: any) => {
      const { code, data } = res;
      if (code === 200) {
        materialOpts.value = data.records || [];
      }
    });
  };
  return {
    formState,
    loading,
    formDataRef,
    materialOpts,
    getAllMaterialOpts
  };
}
